import unittest
from pygo1963.model.Board import Board
from pygo1963.model.Constants import WHITE_COLOR, BLACK_COLOR
from pygo1963.model.Move import Move
from pygo1963.goLogic.GoRules import GoRules
from pygo1963.model.Vertex import Vertex


class GoRulesTest(unittest.TestCase):

    def setUp(self):

        self.board = Board(9)
        self.go_rules = GoRules()

    def test_generate_valid_moves(self):
        
        max_number_of_moves = self.board.size * self.board.size
        
        self.assertEqual(len(self.go_rules.generate_valid_moves(self.board, WHITE_COLOR)), max_number_of_moves)
        
        self.board.make_move(Move(BLACK_COLOR, Vertex(1, 0)))
        
        self.assertEqual(len(self.go_rules.generate_valid_moves(self.board, WHITE_COLOR)), max_number_of_moves - 1)
        
        self.board.make_move(Move(BLACK_COLOR, Vertex(0, 1)))
        
        self.assertEqual(len(self.go_rules.generate_valid_moves(self.board, WHITE_COLOR)), max_number_of_moves - 2)

if __name__ == "__main__":
    unittest.main()